package com.wisezone.workflow.utils;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

/**
 * 文本工具类 2010-05-06
 * @author tss
 *
 */
public class TextUtils {

	
	/**
	 * 获得条件
	 * @param str
	 * @return
	 * @throws Exception
	 */
	public static boolean scriptBoolean(String str) throws Exception{
		
	   return Boolean.valueOf(scriptExec(str));
	}
	
	/**
	 * 执行script 脚本
	 * @param str
	 * @return
	 * @throws Exception
	 */
	public static String scriptExec(String str) throws Exception{
		
		ScriptEngineManager m = new ScriptEngineManager();
        ScriptEngine engine = m.getEngineByExtension("js");
        String s = "var r = "+str;
        engine.eval(s);
        return engine.get("r").toString();
	}
}
